############################################################################
#
# rules.mak
#
# 2018-08-20		zhangtao		File created
#
############################################################################
# Cross compiler prefix
CROSS = aarch64-v01c01-linux-gnu-

# Please remove the following variable definitions if install operation not needed
ifneq ($(DSTROOT),)
LIBCOPYDIR = $(DSTROOT)/libs/
MERGELIBCOPYDIR = $(DSTROOT)/target/
#BINCOPYDIR = $(DSTROOT)/$(PRODUCT_NAME)/Replace
endif

# Global control variables
ifeq ($(verbose), 1)
MAKE := $(MAKE) -C
Q     = 
else
MAKE := $(MAKE) --no-print-directory -C
Q     = @
endif

# Cross compiler
CPP    = echo "  C++       $(subst $(TOPDIR)/,,$@)"; $(CROSS)g++
CC     = echo "  CC        $(subst $(TOPDIR)/,,$@)"; $(CROSS)gcc
LD     = echo "  LD        $(subst $(TOPDIR)/,,$@)"; $(CROSS)ld
AR     = echo "  AR        $(subst $(TOPDIR)/,,$@)"; $(CROSS)ar
RANLIB = echo "  RANLIB    $(subst $(TOPDIR)/,,$@)"; $(CROSS)ranlib
STRIP  = echo "  STRIP     $(subst $(TOPDIR)/,,$@)"; $(CROSS)strip
CP     = echo "  CP        $(subst $(TOPDIR)/,,$@)"; cp -f
RM     = echo "  RM        $(subst $(TOPDIR)/,,$@)"; rm -f

# GNU C compiler flags
CFLAGS += -I$(TOPDIR)/autofocus/inc
CFLAGS += -I$(TOPDIR)/zoombox/inc
CFLAGS += -I$(TOPDIR)/autoexposure/inc
CFLAGS += -I$(TOPDIR)/zoombox/inc_sw
CFLAGS += -I$(TOPDIR)/zoombox/inc_curve
CFLAGS += -I$(TOPDIR)/zoombox/inc_hi3516dv500
CFLAGS += -I$(TOPDIR)/zoomtrace
CFLAGS += -I$(TOPDIR)/ois/inc
CFLAGS += -I$(TOPDIR)/../../../ipz_baseline/branches/3403_64bit/common-headers/Trunk/
ifeq ($(debug), 1)
CFLAGS += -g -O0 -DDEBUG
else
CFLAGS += -Os
endif

ifeq ($(sharedlib), 1)
SHARED += -fpic
SHARED += -shared -o
endif


SVN_URL:=$(shell ${TOPDIR}/svninfo.sh ${TOPDIR} "url")
SVN_REVISION:=$(shell ${TOPDIR}/svninfo.sh ${TOPDIR} "revision")
CFLAGS += -DSVN_URL=\"$(SVN_URL)\" -DSVN_REVISION=\"$(SVN_REVISION)\"

#The C and C++ standards allows the character type char to be signed or unsigned, 
#depending on the platform and compiler. Most systems, 
#including x86 GNU/Linux and Microsoft Windows, use signed char, 
#but those based on PowerPC and ARM processors typically use unsigned char
#This can lead to unexpected results when porting programs between platforms 
#which have different defaults for the type of char
CFLAGS += -Wall
CFLAGS += -ffunction-sections -fdata-sections -fsigned-char -fno-strict-aliasing
#CFLAGS += -fomit-frame-pointer
CFLAGS += -Wformat -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -Wno-strict-aliasing -Wno-format-extra-args
CFLAGS += -D_REENTRANT -D_GNU_SOURCE -DLIBDVR_BUILD -DVN_IPC -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
CFLAGS += -D_BIT_FIELDS_LTOH


# GNU C++ compiler flags
CXXFLAGS := $(CFLAGS)

# Compiler flags onnly supported for C
CFLAGS += -Wno-strict-prototypes

# GNU AR flags
ARFLAGS = cru

# GNU LD flags
LDFLAGS += -Wl,--gc-sections -lpthread -lm -lstdc++
